<?php
require(__META_CONTROLS_GEN__ . '/SchoolMarketingMetaControlGen.class.php');

/**
 * This is a MetaControl customizable subclass, providing a QForm or QPanel access to event handlers
 * and QControls to perform the Create, Edit, and Delete functionality of the
 * SchoolMarketing class.  This code-generated class extends from
 * the generated MetaControl class, which contains all the basic elements to help a QPanel or QForm
 * display an HTML form that can manipulate a single SchoolMarketing object.
 *
 * To take advantage of some (or all) of these control objects, you
 * must create a new QForm or QPanel which instantiates a SchoolMarketingMetaControl
 * class.
 *
 * This file is intended to be modified.  Subsequent code regenerations will NOT modify
 * or overwrite this file.
 *
 * @package My QCubed Application
 * @subpackage MetaControls
 */
class SchoolMarketingMetaControl extends SchoolMarketingMetaControlGen {
    // Initialize fields with default values from database definition
    /*
		public function __construct($objParentObject, SchoolMarketing $objSchoolMarketing) {
			parent::__construct($objParentObject,$objSchoolMarketing);
			if ( !$this->blnEditMode ){
				$this->objSchoolMarketing->Initialize();
			}
		}
    */

    public function SaveSchoolMarketing() {
        try {
            $dttTime = new QDateTime();
            $dttTime->setDate (date("Y"), date("m"), date("d"));
            $dttTime->setTime (date("H"), date("i"), date("s"));

            $CurrentUser = $_SESSION['User']['Id'];
            //should change user
            $Euser       = $_SESSION['User']['Id'];
            $this->objSchoolMarketing->Euser = $Euser;
            // Update any fields for controls that have been created

            $this->objSchoolMarketing->SchoolId = $_SESSION['Org']->Id;
            //if ($this->lstSeason) $this->objSchoolMarketing->SeasonId = $this->lstSeason->SelectedValue;

            if ($this->blnEditMode) {
                //Updating
                $this->objSchoolMarketing->UpdateBy   = $CurrentUser;
                $this->objSchoolMarketing->UpdateDate = $dttTime;
            }
            else {
                //New
                $this->objSchoolMarketing->CreateBy   = $CurrentUser;
                $this->objSchoolMarketing->CreateDate = $dttTime;
            }



            // Update any fields for controls that have been created


            if ($this->lstSchoolType) $this->objSchoolMarketing->SchoolTypeId = $this->lstSchoolType->SelectedValue;
            if ($this->lstEduSystem) $this->objSchoolMarketing->EduSystemId = $this->lstEduSystem->SelectedValue;
            if ($this->lstSegment) $this->objSchoolMarketing->SegmentId = $this->lstSegment->SelectedValue;
            if ($this->lstSector) $this->objSchoolMarketing->SectorId = $this->lstSector->SelectedValue;
            if ($this->lstOrderType) $this->objSchoolMarketing->OrderTypeId = $this->lstOrderType->SelectedValue;
            if ($this->txtOrderNote) $this->objSchoolMarketing->OrderNote = $this->txtOrderNote->Text;

            // Update any UniqueReverseReferences (if any) for controls that have been created for it

            // Save the SchoolMarketing object
            $this->objSchoolMarketing->Save();

            // Finally, update any ManyToManyReferences (if any)
        } catch (QCallerException $objExc) {
            $objExc->IncrementOffset();
            throw $objExc;
        }
    }

}
?>